package com.ckg.service.impl;

import com.ckg.service.PaymentGateway;
import com.ckg.service.SecurityService;

public class PaymentGatewayImpl implements PaymentGateway {
    private final SecurityService securityService; // 强制依赖
    private String merchantId; // 简单类型
    private String apiKey; // 简单类型

    public PaymentGatewayImpl(SecurityService securityService) {
        this.securityService = securityService;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public void setApiKey(String apiKey) {
        this.apiKey = apiKey;
    }

    @Override
    public void processPayment(double amount) {
        if (securityService.validate(apiKey)) {
            System.out.printf("💰 支付宝支付成功! 商户: %s, 金额: %.2f%n", merchantId, amount);
        } else {
            System.out.println("❌ 安全验证失败，支付终止");
        }
    }
}
